function addRow() {
    var table = document.getElementById('datatable');
    var passwordtext = document.getElementById('passwordtext').value;
    if (passwordtext != '') {
        var newRow = table.insertRow(-1);
        var newCell1 = newRow.insertCell(0);
        var newCell2 = newRow.insertCell(1);
        var newCell3 = newRow.insertCell(2);
        var trCnt = document.getElementsByTagName('tr').length;
        trCnt = trCnt - 1;
        console.log(trCnt);
        var date = new Date();
        var year = date.getFullYear();
        var month = date.getMonth() + 1;
        var day = date.getDate();
        newCell1.innerText = month + "/" + day + "/" + year;
        newCell2.innerText = passwordtext;
        newCell3.innerHTML = '<td><button class="w-btn-indigo" id="' + trCnt + '" type="button" value="deldata" onclick="delRow(id)">del</button></td>';
        newRow.id = "tr" + trCnt;
    }
    else {
        alert('Enter the book name');
    }
}
function update() {
    var trCnt = document.getElementsByTagName('tr').length;
    var allbook = document.getElementById('allbook');
    console.log(allbook);
    trCnt = trCnt - 1;
    allbook.setAttribute('value', 'Student name is John He has ' + trCnt + ' books');
}
function delRow(rownum) {
    console.log(rownum);
    document.getElementById("tr" + rownum).outerHTML = "";
    update();
}
